package com.gitee.yangtianle.redisson.seckill.spring.boot.autoautoconfigure;

import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.AdviceModeImportSelector;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author tianle.ytl
 * @date 2018/9/19
 */
public class CurrentLimitingConfigurationSelector extends AdviceModeImportSelector<EnableCurrentLimiting> {

    private final static String REDISSON_CONFIGURATION_CLASS
            = "com.gitee.yangtianle.redisson.seckill.spring.boot.autoautoconfigure.config.RedissonAutoConfiguration";
    private final static String RATELIMITER_CONFIGURATION_CLASS
            = "com.gitee.yangtianle.redisson.seckill.spring.boot.autoautoconfigure.config.RateLimiterAutoConfiguration";
    private final static String WEBINTERCEPTORS_CONFIGURATION_CLASS
            = "com.gitee.yangtianle.redisson.seckill.spring.boot.autoautoconfigure.WebConfigInterceptors";

    @Override
    protected String[] selectImports(AdviceMode adviceMode) {
        List<String> result = new ArrayList<>();
        result.add(REDISSON_CONFIGURATION_CLASS);
        result.add(RATELIMITER_CONFIGURATION_CLASS);
        result.add(WEBINTERCEPTORS_CONFIGURATION_CLASS);
        return StringUtils.toStringArray(result);
    }
}
